package com.group01.community.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.group01.community.entity.SysLogininfor;
import com.group01.community.mapper.SysLogininforMapper;
import com.group01.community.service.SysLogininforService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 系统访问记录 服务实现类
 * </p>
 *
 * @author guoyuan
 * @since 2025-05-01
 */
@Service
public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, SysLogininfor> implements SysLogininforService {
    @Resource
    private SysLogininforMapper sysLogininforMapper;

    @Override
    public IPage<SysLogininfor> selectCondition(SysLogininfor sysLogininfor, Long current, Long size) {
        String[] loginTime = null;
        if ("".equals(sysLogininfor.getLoginTime()) || sysLogininfor.getLoginTime() == null) {
            loginTime = new String[]{"", ""};
        } else {
            loginTime = sysLogininfor.getLoginTime().split(",");
        }
        return sysLogininforMapper.selectCondition(sysLogininfor, loginTime[0], loginTime[1], new Page<>(current, size));
    }
}
